<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery("#draggable").draggable({ disabled: true });
        jQuery("div.socialmediatoolboxes_wiwi_header").css('cursor','auto');
    });
    jQuery('ul.video-list li').click(function() {
        var videoId = jQuery(this).attr('videoId');
        var post_data = "page=stToolBar&action=showYoutubePage&ajax=1&videoId="+videoId;
        var ajax_url = location.href;
        jQuery.ajax({
            type: "POST",
            url: ajax_url,
            data: post_data,
            cache: false,
            beforeSend: function(){
                jQuery.blockUI({
                    message: jQuery('#loading'),
                    css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#000',
                        '-webkit-border-radius': '10px',
                        '-moz-border-radius': '10px',
                        opacity: .5,
                        color: '#fff'
                    }});
            }, //show loading just when link is clicked
            complete: function(){
                jQuery.unblockUI();
            }, //stop showing loading when the process is complete
            success: function(data){
                jQuery("#toolbaContent").html(data);
                jQuery("#draggable").fadeIn();
                
            }
        });
    });
</script>
<div class="socialmediatoolboxes_wiwi_body_main" style="height: 430px;">
    <div id="socialmediatoolboxes_wiwi_bl">
    </div>
    <div id="youtubeVideo"  class="socialmediatoolboxes_wiwi_body" style="height: 430px; width: 790px; padding-top:5px;">
        <div class="socialmediatoolboxes_tw_left_panel"> 
            <div id="socialmediatoolboxes_tw_body_left">
                <?php
                if (empty($current_video_id)) {
                    if(is_array($videoUploads)){
                        foreach ($videoUploads as $videoEntry) {
                            $video_id = $videoEntry->getVideoId();
                            $video_views = $videoEntry->getVideoViewCount();
                            break;
                        }                    
                    }else{
                        foreach ($videoFavourites as $videoEntry) {
                            $video_id = $videoEntry->getVideoId();
                            if ($video_id == $current_video_id) {
                                $video_views = $videoEntry->getVideoViewCount();
                                break;
                            }
                        }
                    }
                } else {
                    $got_video = false;
                    foreach ($videoUploads as $videoEntry) {
                        $video_id = $videoEntry->getVideoId();
                        if ($video_id == $current_video_id) {
                            $video_views = $videoEntry->getVideoViewCount();
                            $got_video = true;
                            break;
                        }
                    }
                    if (!$got_video) {
                        foreach ($videoFavourites as $videoEntry) {
                            $video_id = $videoEntry->getVideoId();
                            if ($video_id == $current_video_id) {
                                $video_views = $videoEntry->getVideoViewCount();
                                break;
                            }
                        }
                    }
                    $video_views = $videoEntry->getVideoViewCount();
                }
                ?>
                <object width="440" height="300">
                    <param name="movie" value="http://www.youtube.com/v/<?php echo $video_id; ?>"></param>
                    <param name="allowFullScreen" value="true"></param>
                    <param name="allowscriptaccess" value="always"></param>
                    <param name="allowFullScreen" value="true"></param>
                    <param name="wmode" value="transparent"></param>
                    <embed src="http://www.youtube.com/v/<?php echo $video_id; ?>"
                           type="application/x-shockwave-flash" allowscriptaccess="always"
                           allowfullscreen="true" width="440" height="300" wmode="transparent">
                    </embed>
                </object>
<!--                <iframe title="YouTube video player" width="440" height="300" src="http://www.youtube.com/embed/<?php echo $video_id; ?>" frameborder="0" allowfullscreen wmode="transparent"></iframe>-->
                <br clear="both" />                
                <div id="comment_panel" >
                    <ul class="comment-list">
                        <?php
                        if($video_id){
                            $commentFeed = $youtubeObject->getVideoCommentFeed($video_id);
                            $j = 0;
                            foreach ($commentFeed as $commentEntry) {
                                $j++;
                            }
                            $i = 0;                        
                            foreach ($commentFeed as $commentEntry) {
                                if ($i == 2)
                                    break;
                                if ($i == $j-1 || $i == 1) {
                                    $class_border_none = 'border_none';
                                } else {
                                    $class_border_none = '';
                                }
                        ?>
                            <li class="comment <?php echo $class_border_none ?>">
                                <div class="content">
                                    <div dir="ltr" class="comment-text">
                                        <p style="margin-bottom: 0"><?php echo $commentEntry->title->text ?></p>
                                    </div>
                                </div>
                                <div class="metadata" style="color: red">
                                <?php echo $commentEntry->author[0]->name->text ?>
<!--                                    <span class="time"><?php echo $commentEntry->updated->text ?></span>-->
                            </div>
                        </li>
                        <?php
                                    $i++;
                                }
                        }
                        ?>
                        </ul>
                    </div>
                    Views ( <?php echo $video_views ?> ) All comments ( <?php echo $i ?> )
                    <a style="float: right" href="http://www.youtube.com/watch?v=<?php echo $video_id; ?>" target="_blank"> Video on Youtube</a>
                    <br clear="both" />

                </div>
            </div>
            <div class="socialmediatoolboxes_Yt_right_panel">
                <div id="socialmediatoolboxes_tw_loader_right" class="socialmediatoolboxes_tw_loader" style="display: none;">
                    <div class="socialmediatoolboxes_tw_loader_img"><img src="<?php echo $config ['frontendCss'] ?>facebook/images/loading.gif"/></div>
                </div>
                <div id="socialmediatoolboxes_tw_body_right" class="socialmediatoolboxes_tw_body">
                    
                    <div style="position: relative; z-index: 0" class="socialmediatoolboxes_tw_stream_body">
                        <h4 class="first">Uploads</h4>
                        <ul class="video-list" id="watch-related">
                        <?php
                            $current_video_id = $video_id;
                            $i = 0;
                            foreach ($videoUploads as $videoEntry) {

                                if ($i == 3)
                                    break;
                                $video_id = $videoEntry->getVideoId();
                                $video_title = $videoEntry->getVideoTitle();
                                $video_views = $videoEntry->getVideoViewCount();
                                if ($current_video_id == $video_id)
                                    $class = 'hover';
                                else
                                    $class = '';
                        ?>
                            <li style="margin-bottom: 5px" onclick="stToolbar.youtubeElementClick('<?php echo $video_id ?>')" class="video-list-item " >
                                <a class="video-list-item-link <?php echo $class ?>" href="javascript:">
                                    <span class="playlist-video-thumbs" style="position: relative; z-index: 0">
                                        <span class="video-thumb ux-thumb-96 ">
                                            <span class="clip">
                                                <img alt="Thumbnail" src="http://i2.ytimg.com/vi/<?php echo $video_id ?>/default.jpg">
                                            </span>
                                        </span>
                                    </span>
                                    <span title="<?php echo $video_title ?>" class="title" dir="ltr"><?php echo $video_title ?></span>
                                    <span class="stat view-count"><?php echo empty($video_views) ? 0 : number_format($video_views, 0, '.', ',') ?> views</span>

                                </a>
                            </li>

                        <?php
                                $i++;
                            }
                        ?>

                        </ul>
                        <br clear="both" />
                        <h4 class="first">Favorites</h4>
                        <ul class="video-list" id="watch-related">
                        <?php
                            $i = 0;
                            foreach ($videoFavourites as $videoEntry) {
                                if ($i == 3)
                                    break;
                                $video_id = $videoEntry->getVideoId();
                                $video_title = $videoEntry->getVideoTitle();
                                $video_views = $videoEntry->getVideoViewCount();
                                if ($current_video_id == $video_id)
                                    $class = 'hover';
                                else
                                    $class = '';
                        ?>
                            <li style="margin-bottom: 5px" onclick="stToolbar.youtubeElementClick('<?php echo $video_id ?>')" class="video-list-item " videoId="<?php echo $video_id ?>">
                                <a class="video-list-item-link <?php echo $class ?>" href="javascript:">
                                    <span class="playlist-video-thumbs" style="position: relative; z-index: 0">
                                        <span class="video-thumb ux-thumb-96 ">
                                            <span class="clip">
                                                <img alt="Thumbnail" src="http://i2.ytimg.com/vi/<?php echo $video_id ?>/default.jpg">
                                            </span>
                                        </span>
                                    </span>
                                    <span title="<?php echo $video_title ?>" class="title" dir="ltr"><?php echo $video_title ?></span>
                                    <span class="stat view-count"><?php echo empty($video_views) ? 0 : number_format($video_views, 0, '.', ',') ?> views</span>

                                </a>
                            </li>

                        <?php
                                $i++;
                            }
                        ?>
                    </ul>
                    <br clear="both" />
                </div>
            </div>
            <br clear="both" />
        </div>
    </div>
    <div id="socialmediatoolboxes_wiwi_br">
    </div>
</div>